package com.boyuan.huijiaoyu;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.magicsoft.app.wcf.HomeService;
import com.magicsoft.app.wcf.listener.PostRecordResponseListener;

/**
 * 邀请同事
 */
public class InviteRegisterActivity extends BaseActivity implements
		OnClickListener {

	private RelativeLayout btnBack;
	private TextView txt_title;
	private WebView webview;
	private String tag = "InviteRegisterActivity";
	private HomeService homeService;
	private String backtitle;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.invite_register_activity);
		prepareView();
	}


	private void prepareView() {
		btnBack = (RelativeLayout) findViewById(R.id.myback);
		btnBack.setOnClickListener(this);
		Intent intent = getIntent();
		backtitle = intent.getStringExtra("backtitle");
		TextView tvback = (TextView) findViewById(R.id.tv_myback);
		tvback.setText(backtitle);
		txt_title = (TextView) findViewById(R.id.txt_title);
		txt_title.setText("我的二维码");
		webview = (WebView) findViewById(R.id.webView1);
		SharedPreferences sp = getSharedPreferences("a.xml", 0);
		String id = sp.getString("id", "");
		getQrcode("employee",id,"contact","down");
	}

	
	private void getQrcode(String objectType, String id, String action,
			String content) {
		if(homeService == null){
			homeService = new HomeService(this);
		}
		
		homeService.getQrcode(objectType, id, action, content, new PostRecordResponseListener() {
			
			@Override
			public void onFinish(String succString) {
				Log.e(tag, "Url ="+succString);
				webview.loadUrl(succString);
			}
			
			@Override
			public void onFailed(String failString) {
				
			}
		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.myback:
			finish();
			break;

		default:
			break;
		}
	}

	@Override
	public void backClicked() {
		isBackAllowed = true;
	}

}
